home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 4 / Gold Medal Software - Volume 4 (Gold Medal) (1994).iso / os2 / svd110.arj / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-28  |  13KB  |  472 lines

  1. /*
  2.  
  3. @echo off
  4. cls
  5. echo.
  6. echo This INSTALL routine requires OS/2 REXX support installed.
  7. echo Run Selective Installation from the OS/2 Setup Folder to
  8. echo install REXX support before attempting to run this CMD file.
  9. pause
  10. exit
  11.  
  12.         *---------------------------------------------------------*
  13.         |                                                         |
  14.         | INSTALL.CMD -- Install procedure for Super Virtual Disk |
  15.         |                (c) Copyright 1994 Albert J. Shan        |
  16.         |                All Rights Reserved                      |
  17.         |                                                         |
  18.         *---------------------------------------------------------*
  19. */
  20.  
  21. '@echo off'
  22.  
  23. BootDrive       = ''
  24. InstallPath     = ''
  25. ItemChecked.1   = ' '
  26. ItemChecked.2   = ' '
  27. ItemChecked.3   = ' '
  28. ItemChecked.4   = ' '
  29. InstallList.0   = 'INSTALL.CMD'
  30. InstallList.1   = 'SVDISK.SYS'
  31. InstallList.2   = 'SVDC.EXE'
  32. InstallList.3   = 'PMSVDC.EXE'
  33. InstallList.4   = 'HFORMAT.EXE'
  34. InstallList.5   = 'HMOUNT.EXE'
  35. InstallList.6   = 'REREGSVD.EXE'
  36. InstallList.7   = 'KWIKTOOL.MSG'
  37. InstallList.8   = 'SVDISK.MSG'
  38. InstallList.9   = 'PMSVDC.MSG'
  39. InstallList.10  = 'HFORMAT.MSG'
  40. InstallList.11  = 'HMOUNT.MSG'
  41. InstallList.12  = 'KWIKTOOL.GER'
  42. InstallList.13  = 'SVDISK.GER'
  43. InstallList.14  = 'PMSVDC.GER'
  44. InstallList.15  = 'HFORMAT.GER'
  45. InstallList.16  = 'HMOUNT.GER'
  46. InstallList.17  = 'SVDISK.DOC'
  47. InstallList.18  = 'SVDISK.HST'
  48. InstallList.19  = 'LICENSE.DOC'
  49. InstallList.20  = 'WARRANTY.DOC'
  50. InstallList.21  = 'ORDER.FRM'
  51. InstallList.22  = 'README'
  52. InstallList.23  = ''
  53. MessageFile.0   = 'PMSVDC'
  54. MessageFile.1   = 'KWIKTOOL'
  55. MessageFile.2   = 'SVDISK'
  56. MessageFile.3   = 'HFORMAT'
  57. MessageFile.4   = 'HMOUNT'
  58. MessageFile.5   = ''
  59. CopyrightLine1  = 'Install procedure for Super Virtual Disk'
  60. CopyrightLine2  = '(c) Copyright 1994 Albert J. Shan'
  61. CopyrightLine3  = 'All Rights Reserved'
  62.  
  63. /* Load REXXUTIL */
  64. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  65. call sysloadfuncs
  66.  
  67. /* Check to make sure all distribution files are found */
  68. i = 0
  69. do while InstallList.i \= ''
  70.   call SysFileTree InstallList.i, 'tmp', 'F'
  71.   if tmp.0 = 0 then do
  72.     say
  73.     say 'Cannot locate one of the distribution files.'
  74.     say 'Please make sure INSTALL.CMD is run from the'
  75.     say 'directory or drive where the distribution'
  76.     say 'files can be found.'
  77.     exit
  78.   end
  79.   i = i + 1
  80. end
  81.  
  82. AvailDrives = SysDriveMap('C:', 'LOCAL')
  83.  
  84. /* Get boot drive letter */
  85. done = 0
  86. do while \ done
  87.   call ShowCopyright
  88.   say '  Please enter the drive letter for your OS/2 boot drive.'
  89.   call charout, '  Press the letter for the drive or ESC to quit: '
  90.   do forever
  91.     k = translate(SysGetKey('NOECHO'))
  92.     if k = D2C(27) then
  93.       call InstallEnd
  94.     else do
  95.       k = k||':'
  96.       if pos(k, AvailDrives) = 0 then
  97.         call beep 1760, 50
  98.       else do
  99.         call SysFileTree k||'\Config.Sys', 'tmp', 'F'
  100.         if tmp.0 = 0 then do
  101.           say
  102.           say
  103.           say 'Cannot locate "'k'\Config.Sys"'
  104.           call PressAnyKey
  105.           leave
  106.         end
  107.         else do
  108.           BootDrive = k
  109.           done = 1
  110.           leave
  111.         end
  112.       end
  113.     end
  114.   end
  115. end
  116.  
  117. /* Check to see if Config.sys contains SVDISK.SYS.  If so, grab the path
  118.    where SVDISK.SYS is installed at. */
  119. do until lines(BootDrive||'\Config.sys') = 0
  120.   parse value linein(BootDrive||'\Config.sys') with ConfigLine
  121.   position = pos('SVDISK.SYS', strip(translate(ConfigLine)))
  122.   if position > 0 & substr(strip(translate(ConfigLine)), 1, 7) = 'DEVICE=' then do
  123.     InstallPath = substr(strip(ConfigLine), 8, position - 9)
  124.     if length(InstallPath) = 1 then
  125.       InstallPath = InstallPath||'\'
  126.   end
  127. end
  128. call lineout BootDrive||'\Config.sys'
  129.  
  130. /* main selection loop */
  131. do forever
  132.   call ShowCopyright
  133.   say 'Select one of the following:'
  134.   say
  135.   say '  ['||ItemChecked.1||'] 1. Install Super Virtual Disk'
  136.   say '  ['||ItemChecked.2||'] 2. Language (message files) selection'
  137.   say '  ['||ItemChecked.3||'] 3. Create PM SVDisk Control object on the Desktop'
  138.   say '  ['||ItemChecked.4||'] 4. Transfer registration info from a registered copy of SVDisk'
  139.   say
  140.   say '  ESC to quit'
  141.   say
  142.   call charout, 'Press 1, 2, 3, 4 or ESC: '
  143.   do forever
  144.     k = translate(SysGetKey('NOECHO'))
  145.     if k = '0' | k = D2C(27) then
  146.       call InstallEnd
  147.     else do
  148.       if k = '1' then do
  149.         call InstallFiles
  150.         leave
  151.       end
  152.       if k = '2' then do
  153.         call SelectLanguage
  154.         leave
  155.       end
  156.       if k = '3' then do
  157.         call CreatePMSVDiskObject
  158.         leave
  159.       end
  160.       if k = '4' then do
  161.         call UpgradeRegSVD
  162.         leave
  163.       end
  164.     end
  165.     call beep 1760, 50
  166.   end
  167. end
  168.  
  169. /* Main install routine */
  170. InstallFiles:
  171.   /* If CONFIG.SYS contains SVDISK.SYS, prompt for upgrade */
  172.   if InstallPath \= '' then do
  173.     call ShowCopyright
  174.     say 'An existing copy of SVDisk is found in '||InstallPath
  175.     say 'If this is a registered copy, you can use it to upgrade'
  176.     say 'the Shareware version into the registered version.'
  177.     say
  178.     call charout, 'Proceed with upgrade? (Y/N) '
  179.     do forever
  180.       k = translate(SysGetKey('NOECHO'))
  181.       if k = 'N' then
  182.         leave
  183.       if k = 'Y' then do
  184.         call UpgradeRegSVD
  185.         leave
  186.       end
  187.       call beep 1760, 50
  188.     end
  189.   end
  190.  
  191.   /* Query new installation path */
  192.   do forever
  193.     call ShowCopyright
  194.     call charout, '  Super Virtual Disk will be installed into '
  195.     if InstallPath \= '' then
  196.       say InstallPath
  197.     else say BootDrive||'\SVDisk'
  198.     say
  199.     say 'Press Enter to accept, or type in a new path where'
  200.     say 'you want to install SVDisk.'
  201.     NewPath = GetPath(NewPath)
  202.     if NewPath = '' then do
  203.       if InstallPath = '' then
  204.         NewPath = BootDrive||'\SVDisk'
  205.       else
  206.         NewPath = InstallPath
  207.     end
  208.     error = SysMkDir(NewPath)
  209.     if error \= 5 & error > 0 then do
  210.       say 'Unable to create subdirectory.'
  211.       call PressAnyKey
  212.     end
  213.     else
  214.       leave
  215.   end
  216.   /* Confirm on install */
  217.   if NewPath \= '' then do
  218.     say
  219.     say '  The new install path is: '||NewPath
  220.   end
  221.   say
  222.   call charout, 'Proceed with install? (Y/N) '
  223.   do forever
  224.     k = translate(SysGetKey('NOECHO'))
  225.     if k = 'N' then
  226.       return
  227.     if k = 'Y' then do
  228.       say
  229.       leave
  230.     end
  231.     call beep 1760, 50
  232.   end
  233.  
  234.   InstallPath = NewPath
  235.   call CopyFiles
  236.   call UpdateConfig
  237.   call SelectLanguage
  238.   call ShowCopyright
  239.   call charout, 'Create/update Desktop object for controlling SVDisk? (Y/N) '
  240.   do forever
  241.     k = translate(SysGetKey('NOECHO'))
  242.     if k = 'N' then
  243.       return
  244.     if k = 'Y' then
  245.       leave
  246.     call beep 1760, 50
  247.   end
  248.   call CreatePMSVDiskObject
  249.   return
  250.  
  251.  
  252. /* Language selection */
  253. SelectLanguage:
  254.   call QueryInstallPath
  255.   call ShowCopyright
  256.   say '  You have 2 choices for language selection.  You can select'
  257.   say '  English messages or German messages.'
  258.   say
  259.   say '  NOTE: make sure NONE of the SVDisk executable files are'
  260.   say '        running before making a selection.'
  261.   say
  262.   say '  Press E for English messages'
  263.   say '        G for German messages'
  264.   say '        ESC to quit'
  265.   error = 0
  266.   i = 0
  267.   do forever
  268.     k = translate(SysGetKey('NOECHO'))
  269.     if k = D2C(27) then return
  270.     if k = 'E' then do
  271.       EXT1 = '.GER'
  272.       EXT2 = '.ENG'
  273.       leave
  274.     end
  275.     if k = 'G' then do
  276.       EXT1 = '.ENG'
  277.       EXT2 = '.GER'
  278.       leave
  279.     end
  280.     call beep 1760, 50
  281.   end
  282.   do until MessageFile.i = ''
  283.     ren InstallPath||'\'||MessageFile.i||'.MSG' MessageFile.i||EXT1 '> nul 2>nul'
  284.     if rc \=0 then
  285.       error = error + 1
  286.     ren InstallPath||'\'||MessageFile.i||EXT2 MessageFile.i||'.MSG' '> nul 2>nul'
  287.     if rc \=0 then
  288.       error = error + 1
  289.     i = i + 1
  290.   end
  291.   if error > 0 & error \= i*2 then do
  292.     say
  293.     say 'The language selection may not be successful.  Some'
  294.     say 'message files may be in use by one of the SVDisk'
  295.     say 'executable programs.  Please exit all SVDisk executable'
  296.     say 'programs, and make the language selection again.'
  297.     call PressAnyKey
  298.    end
  299.    else
  300.      ItemChecked.2 = 'X'
  301.   return
  302.  
  303.  
  304. /* Create PM SVDisk control on Desktop */
  305. CreatePMSVDiskObject:
  306.   call ShowCopyright
  307.   call QueryInstallPath
  308.   say
  309.   if SysCreateObject('WPProgram', 'SVDisk Control', '<WP_DESKTOP>',,
  310.                      'OBJECTID=<PMSVDC>;EXENAME=PMSVDC.EXE;'||,
  311.                      'STARTUPDIR='||InstallPath||';PROGTYPE=PM;', 'U') then do
  312.     say 'Object created successfully.'
  313.     ItemChecked.3 = 'X'
  314.   end
  315.   else
  316.     say 'Failed to create object on the Desktop.'
  317.   call PressAnyKey
  318.   return
  319.  
  320.  
  321. /* Upgrade older registered version of SVDisk to this version */
  322. UpgradeRegSVD:
  323.   call ShowCopyright
  324.   reregsvd InstallPath
  325.   if rc = 0 then do
  326.     say
  327.     say 'Upgrade was successful.  Please proceed with files install.'
  328.     ItemChecked.4 = 'X'
  329.   end
  330.   call PressAnyKey
  331.   return
  332.  
  333.  
  334. /* Show copyright notice */
  335. ShowCopyright:
  336.   call SysCls
  337.   say
  338.   say
  339.   say CopyrightLine1
  340.   say CopyrightLine2
  341.   say CopyrightLine3
  342.   say
  343.   say
  344.   return
  345.  
  346.  
  347. /* Wait for a key press */
  348. PressAnyKey:
  349.   call charout, 'Press any key to continue...'
  350.   call SysGetKey 'NOECHO'
  351.   return
  352.  
  353.  
  354. /* Get path from user */
  355. GetPath:
  356.   call charout, '> '
  357.   parse pull APath
  358.   len = length(APath)
  359.   if len > 0 then
  360.     if substr(APath, len, 1) = '\' then
  361.       APath = substr(APath, 1, len-1)
  362.   return APath
  363.  
  364.  
  365. /* Query installation path if not already set */
  366. QueryInstallPath:
  367.   if InstallPath = '' then do
  368.     call ShowCopyright
  369.     say 'Enter the path where SVDisk is installed.'
  370.     InstallPath = GetPath(InstallPath)
  371.   end
  372.   return
  373.  
  374.  
  375. /* Copy distribution files to the install path */
  376. CopyFiles:
  377.   call ShowCopyright
  378.   /* Remove *.ENG, *.GER files */
  379.   i = 0
  380.   do until MessageFile.i = ''
  381.     del InstallPath||'\'||MessageFile.i||'.ENG' '> nul 2>nul'
  382.     del InstallPath||'\'||MessageFile.i||'.GER' '> nul 2>nul'
  383.     i = i + 1
  384.   end
  385.   i = 0
  386.   do until InstallList.i = ''
  387.     say '  Copying '||substr(InstallList.i, 1, 12, ' ')||' to '||InstallPath
  388.     copy InstallList.i InstallPath '> nul 2>nul'
  389.     if rc \= 0 then do
  390.       say
  391.       say 'Unable to copy '||InstallList.i||' to '||InstallPath
  392.       say 'The file may be missing or the disk may be full.'
  393.       exit
  394.     end
  395.     i = i + 1
  396.   end
  397.   return
  398.  
  399.  
  400. /* Append InstallPath to end of PATH=/DPATH= if not already in it */
  401. AppendInstallPath:
  402.   position = pos(translate(InstallPath), translate(ConfigLine))
  403.   if position = 0 then do
  404.     len = length(ConfigLine)
  405.     if substr(ConfigLine, len, 1) = ';' then
  406.       return substr(ConfigLine, 1, len)||InstallPath
  407.     else
  408.       return substr(ConfigLine, 1, len)||';'||InstallPath
  409.   end
  410.   return ConfigLine
  411.  
  412.  
  413. /* Update CONFIG.SYS for path/dpath */
  414. UpdateConfig:
  415.   FoundDevice = 0
  416.   call ShowCopyright
  417.   call charout, 'Updating '||BootDrive||'\Config.sys ... '
  418.   call linein BootDrive||'\Config.sys', 1, 0
  419.   NewConfig = SysTempFileName(BootDrive||'\Config.???')
  420.   do until lines(BootDrive||'\Config.sys') = 0
  421.     parse value linein(BootDrive||'\Config.sys') with ConfigLine
  422.     if substr(strip(translate(ConfigLine)), 1, 9) = 'SET PATH=' then
  423.       ConfigLine = AppendInstallPath(ConfigLine)
  424.     if substr(strip(translate(ConfigLine)), 1, 10) = 'SET DPATH=' then
  425.       ConfigLine = AppendInstallPath(ConfigLine)
  426.     position = pos('SVDISK.SYS', strip(translate(ConfigLine)))
  427.     if position > 0 & substr(strip(translate(ConfigLine)), 1, 7) = 'DEVICE=' then do
  428.       ConfigLine = substr(strip(ConfigLine), 1, 7)||InstallPath||,
  429.                    '\'||substr(ConfigLine, position, length(strip(ConfigLine))-position+1)
  430.       FoundDevice = 1
  431.     end
  432.     position = pos('SVDC.EXE', strip(translate(ConfigLine)))
  433.     if position > 0 & substr(strip(translate(ConfigLine)), 1, 5) = 'CALL=' then
  434.         ConfigLine = substr(strip(ConfigLine), 1, 5)||InstallPath||,
  435.                      '\'||substr(ConfigLine, position, length(strip(ConfigLine))-position+1)
  436.     call lineout NewConfig, ConfigLine
  437.   end
  438.   /* Did we process any SVDISK.SYS?  If not, add a 1.44MB VFloppy by default */
  439.   if FoundDevice = 0 then do
  440.     call lineout NewConfig, 'DEVICE='||InstallPath||'\SVDisk.sys'
  441.     len = length(AvailDrives)
  442.     call lineout NewConfig, 'CALL='||InstallPath||'\SVDC.EXE /i '||,
  443.          D2C(C2D(substr(AvailDrives, len-1, 1))+1)||':'
  444.   end
  445.   call lineout NewConfig
  446.   call lineout BootDrive||'\Config.sys'
  447.   del BootDrive||'\Config.svd' '> nul 2>nul'
  448.   ren BootDrive||'\Config.sys' 'Config.svd' '> nul 2>nul'
  449.   ren NewConfig 'Config.sys' '> nul 2>nul'
  450.   if rc = 0 then do
  451.     say 'success.'
  452.     ItemChecked.1 = 'X'
  453.   end
  454.   else
  455.     say 'failed.'
  456.   call PressAnyKey
  457.   return
  458.  
  459.  
  460. InstallEnd:
  461.   call SysCls
  462.   say
  463.   say
  464.   say 'Super Virtual Disk INSTALL ended.'
  465.   if ItemChecked.1 = 'X' then do
  466.     say
  467.     say 'Config.sys has been updated.  Please shutdown and reboot'
  468.     say 'for the new changes to take effect.'
  469.   end
  470.   exit
  471.  
  472.